public class Test {
    public static void main(String[] args) {
        String s = "love live! mu'sic forever";
        System.out.println(Solution.countSegments(s));
    }
}
class Solution {
    public static int countSegments(String s) {
        if(s.length() == 0) {
            return 0;
        }
        int count = 0;
        String[] arr = s.split(" ");
        for (int i = 0; i < arr.length; i++) {
            if(arr[i].length() != 0) {
                count++;
            }
        }
        return count;
    }
}
